package com.atwisdom.star.controller;

import com.alibaba.fastjson.JSONObject;
import com.atwisdom.star.common.vo.ActionData;
import com.atwisdom.star.common.vo.JsonResult;
import com.atwisdom.star.common.vo.ResultInfo;
import com.atwisdom.star.core.bsl.business.Impl.DataChangeBslServiceImpl;
import com.atwisdom.star.core.bsl.functionClass.impl.ApiConfigBslServiceImpl;
import com.atwisdom.star.exception.pojo.BusinessException;
import com.atwisdom.star.log.aop.StarAnnotation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/config")
public class ApiConfigController {
    private final ApiConfigBslServiceImpl apiConfigBslService;

    private final DataChangeBslServiceImpl dataChangeBslService;

    public ApiConfigController(ApiConfigBslServiceImpl apiConfigBslService,DataChangeBslServiceImpl dataChangeBslService) {
        this.apiConfigBslService = apiConfigBslService;
        this.dataChangeBslService = dataChangeBslService;
    }

    /**
     *
     * @return 返回结果
     * @throws BusinessException  业务异常
     */
    @StarAnnotation
    @PostMapping
    public ResultInfo<?> responseApiConfigFactory(@RequestBody List<ActionData<JSONObject>> actionDataList) throws BusinessException {
        return apiConfigBslService.responseFactory(actionDataList);
    }
    @PostMapping(value = "/test")
    public ResultInfo<?> sendTest() throws BusinessException {
       return dataChangeBslService.sendDataTest();
    }
}
